<?php
/**
 * Created by PhpStorm.
 * User: jsd
 * Date: 2016/8/31
 * Time: 14:40
 */
namespace Admin\Controller;
use Admin\Api\ZengwuxianApi;
use Shop\Api\ProductApi;
use Shop\Model\ProductModel;

class ZengwuxianController extends AdminController {
    public function showlist(){
        $page = array('curpage' => I('get.p', 0), 'size' => 15);
        $result  =  apicall(ZengwuxianApi::QUERY_LIST,[null,$page]);
        if($result['status']){
            $list = $result['info']['list'];
            $show = $result['info']['show'];
            $this->assign('list',$list);
            $this->assign('page',$show);
            $this->display();
        }else{
            $this->error($result['info']);
        }
    }
    public function del(){
        $pid    = I('pid');
        if(empty($pid)){
            $this->error('参数错误！');
        }
        $map = ['id'=>$pid];
        $result  =  apicall(ProductApi::DELETE,[$map]);

        if($result['status']){
            $this->success(L('RESULT_SUCCESS'));
        }else{
            $this->error('操作失败！');
        }
    }


    public function bulkDelete(){
        $pid    = I('pid');
        if(empty($pid)){
            $this->error('参数错误！');
        }
        $map = ['id'=>['in',$pid]];
        $result = apiCall(ProductApi::DELETE,array($map));

        if($result['status']){
            $this -> success(L('RESULT_SUCCESS'));
        }else{
            LogRecord('[INFO]' . $result['info'], '[FILE] ' . __FILE__ . ' [LINE] ' . __LINE__);
            $this->error($result['info']);
        }

    }
        public function detail(){
        $pid    = I('pid');
        if(empty($pid)){
            $this->error('参数错误！');
        }
        $map = ['id'=>$pid];
        $result  =  apicall('Admin/Zengwuxian/detail',$map);
        if($result){
            $this->assign('result',$result);
            $this->display();
        }else{
            $this->error($result['info']);
        }
    }

}
